function [out V D] = rotate_cov(meas, meas_sig)

sz          = length(meas);
if sz==2
    covar     = [(meas(1)*meas_sig(2))^2 0; ...
                  0 meas_sig(1)^2]; % x-range on x-axis, range on y-axis
    R         = [ cos(meas(2))  sin(meas(2));...
                  -sin(meas(2)) cos(meas(2))]; % positive angle clockwise rot
    error('This function is not complete');
elseif sz==3
    covar     = [(meas(1)*meas_sig(2))^2 0 0; ...
                 0 meas_sig(1)^2 0;...
                 0 0 (meas(1)*meas_sig(3))^2];
    %covar     = [1 0.5 0.25; ...
    %             0.5  1 0.5;...
    %             0.25 0.5 1]; 
    R1        = [ cos(meas(2)) sin(meas(2)) 0;...
                 -sin(meas(2)) cos(meas(2)) 0;...
                  0            0            1];
    R2        = [ 1  0             0           ;... 
                  0  cos(meas(3)) -sin(meas(3));...
                  0  sin(meas(3))  cos(meas(3))];
    R         = R1*R2;
    %if rank(R)~=3
    %    error('rank deficient');
    %end
    D = covar;                              % Eigenvals
    V = [R*[1 0 0]' R*[0 1 0]' R*[0 0 1]']; % Eigenvects
else
    error('Input must be a 2D or 3D vector');
end
out       = R*covar*R';